#coding:utf8
import numpy as np
SNR = range(-10,31)
a = [0.272, 0.28, 0.297, 0.324, 0.3454822775515653,
  0.37011227554, 0.3916167145, 0.415221280, 0.426281289, 0.442093318,
  0.44719978639,0.47, 0.5027685, 0.54129363, 0.588812495,
  0.62655563714, 0.6734530405, 0.7147420065, 0.750817702, 0.8226673786796609,
  0.87078232481, 0.9005808029, 0.9339416594, 0.972031239, 0.9761491222214805,
  0.98633664499, 0.9970963220, 0.9992657365, 0.999464721, 0.999432614,1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1
  ]

b = [0.149, 0.15226198514517217, 0.1575354490209318, 0.16952734638757597, 0.1810871033085752,
0.1836596893990547, 0.20168129642133693, 0.21087778528021608, 0.23295070898041864, 0.27211343686698175,
 0.2761647535449021, 0.3176907494935854, 0.35313977042538824, 0.3602295746117488, 0.4037812288993923,
 0.4351789331532748, 0.49054692775151926, 0.5445644834571236, 0.593099257258609, 0.6185820391627279,
  0.7059419311276165, 0.7417285617825793, 0.7967589466576638, 0.8281566509115462, 0.8443619176232275,
  0.8923024983119514, 0.9446320054017556, 0.962187711006077, 0.9824442943956786, 0.9854827819041189,
  0.9945982444294396, 0.9976239027684, 0.9986110735989196, 1.0, 1.0,
  1.0, 1.0, 1.0, 1.0, 1.0, 1]

c = [0.07157326130992572, 0.08237677245104659, 0.07933828494260635, 0.09149223497636733, 0.08676569885212694,
 0.07933828494260635, 0.09790681971640783, 0.12187711006076975, 0.1100607697501688, 0.13268062120189061,
 0.15272788656313303, 0.16078325455773127, 0.17581769074949357, 0.19716407832545577, 0.22180958811613774,
 0.24037812288993923, 0.24172856178257934, 0.2886563133018231, 0.32680621201890614, 0.34908845374746794,
 0.4037812288993923, 0.4338284942606347, 0.46725185685347737, 0.5344361917623227, 0.5303848750844025,
 0.6239027683997299, 0.675219446320054, 0.6860229574611749, 0.7609723160027009, 0.7852802160702228,
 0.8419986495611074, 0.8541525995948683, 0.9064821066846726, 0.9233625928426739, 0.9230249831195139,
 0.9436191762322755, 0.9665766374071574, 0.9736664415935179, 0.9827819041188386, 0.9719783929777177,
 0.9819783929777177]
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['simhei'] #用来正常显示中文标签

plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

a = [0.95*(1-x) for x in a]
b = [0.95*(1-x) for x in b]
c = [0.95*(1-x) for x in c]

# a = np.log10(a)
# b = np.log10(b)
# c = np.log10(c)

# print a

# SNR = [np.log10(pow(10, db/20.0)) for db in SNR]


line_lrs, = plt.plot(SNR,a, 'rv-', label='QPSK')
line_mlp, = plt.plot(SNR,b, 'go-', label='8PSK')
line_16psk, = plt.plot(SNR,c, 'bs-', label='16PSK')
plt.legend([line_lrs,line_mlp, line_16psk],['QPSK', '8PSK', '16PSK'])
plt.xlabel(u"信噪比(dB)", fontsize=16)
plt.yscale('log')
plt.ylabel(u"误符号率", fontsize=16)
plt.ylim(0,1)
plt.grid(True)
#plt.show()

plt.savefig('CP4RLS.png')
